<template>
    <div style="flex: 90%; margin-left: 20px">

    <el-dialog v-model="dialogKlineVisible" title="" width="800" style="width:50%;height:100%;margin-left: 50%;margin-top: 0%;">  
      <TimeChartMiniWithAuction />
      <KLineMini />
    </el-dialog>  

      <el-dialog v-model="dialogTableVisible" title="审核条件" width="800" style="width:100%;height:100%;margin: 0;">
        <el-table :data="tableRefCondition">
          <el-table-column property="indicator" label="指标" width="150" />
          <el-table-column property="condition" label="审核条件" width="200" />
          <el-table-column prop="x" label="是否通过"  width="150">
              <template #default="scope">
                <div class="button-container">
                  <el-button type="warning" circle size="small" v-show="shouldShowButton(scope.row, 0)" style="margin-left:12px">待</el-button>
                  <el-button type="danger" :icon="CloseBold" circle size="small" v-show="shouldShowButton(scope.row, 2)"/>               
                  <el-button type="success" :icon="Check" circle size="small" v-show="shouldShowButton(scope.row, 1)"/>
                </div>
              </template>
          </el-table-column>
          <el-table-column prop="审核" label="审核" width="120">
            <template #default="scope">
              <el-select @change="handleConditionIsOk(scope.row, $event)"  v-model="[ '待确定', '通过',  '不通过'][scope.row.isOk]" placeholder="Select" size="small" class="select" >
                <el-option v-for="item in condition_sh_type" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </template>  
          </el-table-column>
        <el-table-column property="规则" label="规则" width="200">

        </el-table-column>
        <el-table-column property="审核理由" label="审核理由" width="800">
          <template #default="scope">
            <el-input
              type="textarea"
              :rows="2"
              placeholder="请输入内容"
              v-model="scope.row.description"
            >
            </el-input>
        </template>
        </el-table-column>
        </el-table>
      </el-dialog>
      
      <el-dialog v-model="isShowRemarkDialogTableVisible" title="编辑" width="1000" >
        <div style="display: flex;">
          <p v-html="data.strB"></p>
        </div>
      </el-dialog>

      <el-dialog v-model="tiggerDialogTableVisible" title="龙虎榜" width="960">
        <el-table :data="tableDataTigger">
          <el-table-column property="strA" label="买卖" width="50" >
            <template #default="scope">
                <el-text :style="{color:getBuySailColor(scope.row.strA)}">{{ scope.row.strA }}</el-text>
            </template>
          </el-table-column>
          <el-table-column property="name" label="席位" width="350" />
          <el-table-column property="realName" label="买入" width="100" >
            <template #default="scope">
                <el-text style="color:#409EFF">{{ scope.row.realName }}</el-text>
            </template>
          </el-table-column>
          <el-table-column property="buyMoney" label="买入" width="100" >
            <template #default="scope">
                <el-text :style="{color:getMoneyColor(scope.row.buyMoney)}">{{ getMoneyStr(scope.row.buyMoney) }}</el-text>
            </template>
          </el-table-column>
          <el-table-column property="sailMoney" label="卖出" width="100" >
            <template #default="scope">
                <el-text :style="{color:getMoneyColor(scope.row.sailMoney)}">{{ getMoneyStr(scope.row.sailMoney) }}</el-text>
            </template>
          </el-table-column>
          <el-table-column property="netMoney" label="净额" width="100" >
            <template #default="scope">
                <el-text :style="{color:getMoneyColor(scope.row.netMoney)}">{{ getMoneyStr(scope.row.netMoney) }}</el-text>
            </template>
          </el-table-column>
          <el-table-column property="allDifMoney" label="合计" width="100" >
            <template #default="scope">
                <el-text :style="{color:getAllDifMoneyColor(scope.row.allDifMoney)}">{{ getAllDifMoney(scope.$index, scope.row.allDifMoney) }}</el-text>
            </template>
          </el-table-column>
        </el-table>
      </el-dialog>

      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="选日期">
          <el-date-picker
                  v-model="data.dateTime"
                  type="date"
                  placeholder="Pick a day"
                  size="large"
                  @change="handleDateChange"
              />
        </el-form-item>
        <el-form-item>
          <el-select @change="handleIndustry($event)"  v-model="industryType" placeholder="Select" size="large" class="select">
            <el-option v-for="item in options_industry" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSearchByDate">下一天</el-button>
          <el-icon style="margin-left:20px;font-size: 24px;color:#409EFF" @click="onLoadScore"><Refresh /></el-icon>
          <el-switch style="margin-left:20px;" v-model="data.v_is_simple" active-icon="" inline-prompt active-text="正常" inactive-text="高度"/>
          <el-switch style="margin-left:20px;" v-model="data.v_open" active-icon="" inline-prompt active-text="开盘" inactive-text="开盘"/>
          <el-switch style="margin-left:20px;" v-model="data.v_close" active-icon="" inline-prompt active-text="收盘" inactive-text="收盘"/>
        </el-form-item>
      </el-form>

      <div style="display: flex;">
        <!--左-->
        <div style="flex:20%;margin-right:10px">

          <el-table
            v-loading="loading"
            row-key="code"
            :data="tableDataScore"
            :style="{width:getTableWidth()}" class="custom-border"
            @sort-change="handleSortChange"
          >
            <el-table-column prop="orderIndex" label="序"  :width="45" >
                <template #default="scope">
                    <el-text >{{scope.$index + 1}}</el-text>
                </template>
            </el-table-column>

            <el-table-column style="color: #990000;" prop="tip" label="暗线" :width="66" >
                <template #default="scope">
                    <el-text style="color:#E6A23C;font-weight: bold;font-size: 13px;">{{scope.row.tip}}</el-text>
                </template>
            </el-table-column>

            <el-table-column prop="orderIndex" label="名称" sortable="custom" :width="110" >
                <template #default="scope">
                    <el-text @mouseover="handleMouseOver(scope.row)">{{scope.row.name}}</el-text>
                </template>
            </el-table-column>

            <el-table-column prop="open" label="开盘" sortable="custom" :width="labWidthChange"  v-if="getIsShow(data.v_open, data.v_is_simple)">
                <template #default="scope">
                    <el-text :style="{color:getIncreaseTextColorCkOpenClose(scope.row.open, scope.row.ckTodayOpen)}">{{getIncreaseData(scope.row.open, scope.row.ckTodayOpen)}}</el-text>
                </template>
            </el-table-column>

            <el-table-column prop="close" label="收盘" sortable="custom" :width="labWidthChange" v-if="getIsShow(data.v_open, data.v_is_simple)">
                <template #default="scope">
                    <el-text :style="{color:getIncreaseTextColorCkOpenClose(scope.row.close, scope.row.ckTodayClose)}">{{getIncreaseData(scope.row.close, scope.row.ckTodayClose)}}</el-text>
                </template>
            </el-table-column>

            <el-table-column prop="x" label="总金额" sortable="custom" :width="100" v-if="data.v_is_simple">
                <template #default="scope">
                    <el-text :style="{color:getIncreaseTextColorCkOpenClose(scope.row.close, scope.row.ckTodayClose)}">{{getMoneyData(scope.row.amount)}}</el-text>
                </template>
            </el-table-column>

            <!-- <el-table-column prop="x" label="封单额" sortable="custom" :width="100" >
                <template #default="scope">
                    <el-text :style="{color:getIncreaseTextColorCkOpenClose(scope.row.close, scope.row.ckTodayClose)}">{{成交金额}}</el-text>
                </template>
            </el-table-column> -->

            <!-- <el-table-column prop="x" label="大单净流入" sortable="custom" :width="120" >
                <template #default="scope">
                    <el-text :style="{color:getIncreaseTextColorCkOpenClose(scope.row.close, scope.row.ckTodayClose)}">{{成交金额}}</el-text>
                </template>
            </el-table-column> -->

            <el-table-column prop="continuousNumber" label="连板" :width="50" >
                <template #default="scope">
                    <el-text>{{scope.row.continuousNumber}}</el-text>
                </template>
            </el-table-column>

            <el-table-column prop="allNumber" label="总板" :width="50" >
                <template #default="scope">
                    <el-text>{{scope.row.allNumber}}</el-text>
                </template>
            </el-table-column>

            <el-table-column prop="increase" label="竞价压力" :width="labWidth" v-if="showStressColumn">
                <template #default="scope">
                    <el-text >{{getStressScore_Yes_str(scope.row)}}</el-text>
                </template>
            </el-table-column>

            <el-table-column prop="increase" label="龙虎榜" :width="80" v-if="data.v_is_simple">
                <template #default="scope">
                  <el-text @click="onLoadTigger(scope.row)" type="primary" plain v-if="shouldShowButtonTigger(scope.row)">
                    龙虎榜
                  </el-text>

                  <a :href="getLink(scope.row)" v-if="isLinkShow()" target="_blank">涨停板</a>
                </template>
            </el-table-column>

            <el-table-column prop="increase" label="炒作逻辑" :width="380" v-if="data.v_is_simple">
              <template #default="scope">
                    <el-text >{{scope.row.note}}</el-text>
                </template>
            </el-table-column>

            <el-table-column prop="increase" label="操作" :width="580" v-if="data.v_is_simple">
                <template #default="scope">
                  <el-text @click="handleRemark(scope.row)" type="primary" plain>
                    详情
                  </el-text>
                </template>
            </el-table-column>

            <el-table-column prop="increase" label="占位" :width="2580" >
                
            </el-table-column>
          </el-table>  
        </div>

        <!--右-->
        <KLineLetf style="flex:70%;margin-top:50px"/>

      </div>

    </div>
  </template>
    
  <script lang="ts" setup>
  import { onMounted, ref , defineEmits} from "vue";
  import type { TableColumnCtx, TableInstance } from "element-plus";
  import { reactive } from "vue";
  import axios from "axios";
  import { countdownEmits, ElMessage, ElMessageBox, ElNotification } from "element-plus";
  import ClipboardJS from 'clipboard';
  import { createStore } from 'vuex';
  import type { Action } from 'element-plus';
  import {Check,Delete,Edit,Message,Search, Star, CloseBold,Close,QuestionFilled
          } from '@element-plus/icons-vue';
  import KLineMini from "./base/KLineMiniComponent.vue";
  import KLineLetf from "./base/KLineLetfComponent.vue";
  import TimeChartMini from "./base/TimeChartMiniComponent.vue";
  import TimeChartMiniWithAuction from "./base/TimeChartMiniWithAuctionComponent.vue";
  
  // ElNotification({
  //   title: '情绪周期',
  //   message: "<p style='color:#008888'>指数</p>",
  //   duration: 0,
  //   dangerouslyUseHTMLString: true,
  //   showClose:false,
  // })
  const localImagePath = ref('file:///F:/typora/1.png');
  const labWidth = ref(70);
  const labWidthChange = ref(80);
  const data = reactive({
    code: "",
    name: "",
    dateTime: "",
    note:"",
    strB:"",
    id:0,
    isSelected:true,
    v_is_simple:true,
    v_open:true,
    v_close:true,
  });
  
  const stressScore = ref(1);
  const industryType = ref("短线");
  const options_industry = [
  { value: 'A股指数' },
                    { value: '同花顺行业板块' },
                    { value: '同花顺概念' },
                    { value: '同花顺概念第2天' },
                    { value: '同花顺热门板块' },
                    { value: 'ETF' },
                    { value: 'ETF第2天' },
                    { value: '情绪' },
                    { value: '短线' },
                    { value: '第2天入场' },
                    { value: '第3天出场' },
                    { value: '龙虎榜' },
                    { value: '龙虎榜第2天' },
                    { value: '东方财富热榜' },
                    { value: '同花顺热榜' },
                    { value: '涨停容量榜' },
                    { value: '负反馈榜' },
                    { value: '今日涨停板' },  
                    { value: '涨停板第2天' },  
                    { value: '涨停板第3天' },  
                    { value: '港股' },
                    { value: '美股' },
                    { value: '中概美股' },
                  ];
  const onLoadScore = () => {
    console.log("submit!");
    const api = "api/plat/stockDayRecord/findPageList1/1/100?recordDate=" + data.dateTime + "&strA=" + encodeURIComponent(industryType.value);
    console.log(api) 
    axios
      .get(api)
      .then((response) => {
        tableDataScore.value = response.data.data.list;
        var list = response.data.data.list;
        stressScore.value = 0;
        for (var i = 0; i < list.length; i++) {
          stressScore.value = stressScore.value + getStressScore_Yes(list[i]);
          console.log("分数：" + stressScore.value);
        }
      })
      .catch((error) => {
        console.error("Error fetching data:", error);
      });
  };

  const onLoadScoreBySort = (orderBy: string) => {
    console.log("submit!");
    const api = "api/plat/stockDayRecord/findPageList/1/100?recordDate=" + data.dateTime + "&strA=" + encodeURIComponent(industryType.value);
    console.log(api) 
    axios
      .get(api)
      .then((response) => {
        tableDataScore.value = response.data.data.list;
        var list = response.data.data.list;
        stressScore.value = 0;
        for (var i = 0; i < list.length; i++) {
          stressScore.value = stressScore.value + getStressScore_Yes(list[i]);
          console.log("分数：" + stressScore.value);
        }
      })
      .catch((error) => {
        console.error("Error fetching data:", error);
      });
  };

  const onLoadTigger = (row:StockNowPrice) => {
    console.log("submit!");
    const api = "api/plat/stockTigger/findPageList/1/50?dayTime=" + data.dateTime + "&code=" + row.code;
    console.log(api) 
    axios
      .get(api)
      .then((response) => {
        tableDataTigger.value = response.data.data.list; 
        tiggerDialogTableVisible.value = true;
      })
      .catch((error) => {
        console.error("Error fetching data:", error);
      });
  };
  
  const onLoadCondition = () => {
    console.log("submit!");
    const api = "api/plat/stockIndicatorOk/findPageList/1/50?recordId=47";
    console.log(api) 
    axios
      .get(api)
      .then((response) => {
        tableRefCondition.value = response.data.data.list;
        dialogTableVisible.value = true;
      })
      .catch((error) => {
        console.error("Error fetching data:", error);
      });
  };

  const onInputChange = (newValue, oldValue) => {
    console.log("Input changed:", newValue);
    const containsChinese = /[\u4e00-\u9fa5]/.test(newValue);
    if (newValue === '') {
      data.isTableVisible = false;
    } else {
      data.isTableVisible = true;
      if (containsChinese) {
        onSearh(newValue, 2);
      } else if (newValue.length == 6) {
        onSearh(newValue, 1);
      }
    }
  };

  const handleIndustry = (value) => {
      industryType.value = value;
      onLoadScore();
  }

  interface stockDayRecord {
    id: number;
    recordDate:string;
    name: string;
    code: string;

    tip: String;

    bidding: number;
    open: number;
    close: number;
    max: number;
    min: number;
    yesOpen: number;
    yestoday: number;
    
    tomOpen: number;
    tomClose: number;

    continuousNumber: number;
    allNumber: number;
    docId: number;

    importantScore: number;
    stressScore: number;

    note: string;
    strB: string;

    ckTodayOpen: number;
    ckTodayClose: number;
    ckTomOpen: number;
    ckTomClose: number;

    ckTodayOpenBoolean: boolean;
    ckTodayCloseBoolean: boolean;
    ckTomOpenBoolean: boolean;
    ckTomCloseBoolean: boolean;

    orderIndex: number;
    intA: number;
    timeList: StockNowTime[];

    amount:number;
  }

  interface StockNowTime {
    timeRecord: string;
    increase: number;
  }

  interface StockIndicatorOk {
    id: number;
    recordId: number;
    indicator: string;
    condition: string;
    isOk: number;
    data: number;
    type: string;
    note: string;
    mark: string;
  }

  interface StockNowPrice {
    id: number;
    name: string;
    tscode: string;
  }

  interface StockTigger {
    code: string;
    buySailType: number;
    name: string;
    realName: string;
    buyMoney: number;
    percent1: number;
    sailMoney: number;
    percent2: number;
    netMoney: number;
    strA: string;
  }

  const showStressColumn = ref(false);
  const isPlay = ref(true);
  const loading = ref(false);
  const tableRefCondition = ref<TableInstance>();
  const tableDataScore = ref([]);
  const tableDataTigger = ref([]);
  const dialogKlineVisible = ref(true)
  const dialogTableVisible = ref(false)
  const isShowRemarkDialogTableVisible = ref(false)
  const tiggerDialogTableVisible = ref(false)

  const score_type = [
                { value: '5',label: '5级', },
                { value: '4',label: '4级', },
                { value: '3',label: '3级' },

                { value: '2',label: '2级' },
                { value: '1',label: '1级' },
                { value: '0',label: '0级' },
            ]
            const condition_sh_type = [
                { value: '2',label: '不通过' },
                { value: '1',label: '通过' },
                { value: '0',label: '待确定' },
            ]
  var code = ''
  const index = ref(0);
  onMounted(() => {
        document.title = "情绪";
        data.dateTime = getToday();
        setInterval(() => {
          index.value = index.value + 1;
          if (index.value >= 100) {
            index.value = 0;
          }
        }, 1000);

        const clipboard = new ClipboardJS('.btn-copy', {
          text: () => code
        });
  
        clipboard.on('success', (e) => {
          console.log('Text copied to clipboard');
          e.clearSelection();
        });
  
        clipboard.on('error', (e) => {
          console.error('Failed to copy text: ', e);
        });
   });
  
   const getNegativeScore_str = (row: stockDayRecord) => {
      var xs = getNegativeScore(row);
      if (xs > 0) {
        return '' + xs;
      }
      return ''; 
    }

    const getNegativeScore = (row: stockDayRecord) => {
      var xs = 0.00;  
      if (row.yestoday <= -3 && row.yestoday > -5) {
        xs = 1;
      }
      if (row.yestoday <= -5 && row.yestoday > -8) {
        xs = 3;
      }
      if (row.yestoday <= -8 && row.yestoday > -10.5) {
        xs = 5;
      }
      xs = xs * row.yestoday / 5.00;
      return xs; 
    }

    const getNegativeScore_Yes_str = (row: stockDayRecord) => {
      var xs = getNegativeScore_Yes(row);
      if (xs > 0) {
        return '' + xs;
      }
      return ''; 
    }
    const getNegativeScore_Yes = (row: stockDayRecord) => {
      var importantScore = 5.0;
      var xs = 0.00;  
      if (row.yestoday <= -3 && row.yestoday > -5) {
        xs = 1;
      }
      if (row.yestoday <= -5 && row.yestoday > -8) {
        xs = 3;
      }
      if (row.yestoday <= -8 && row.yestoday > -10.5) {
        xs = 5;
      }
      xs = 0.6 * xs * importantScore / 5.00;// 昨天的乘以60%
      return xs; 
    }

    const getStressScore_Yes_str = (row: stockDayRecord) => {
      var xs = getStressScore_Yes(row);
      if (xs >= 3) {
        return '' + xs;
      }
      return ''; 
    }

    const getStressScore_Yes = (row: stockDayRecord) => {
      var xs = 0.00;  
      if (row.bidding <= 8 && row.bidding > 5) {
        xs = 1;
      }
      if (row.bidding <= 9.90 && row.yestoday > 8) {
        xs = 2;
      }
      if (row.bidding > 9.90) {
        xs = 3;
      }
      xs = xs * row.stressScore / 3.00;// 昨天的乘以60%
      return xs; 
    }

    const getIncreaseBgColor = (row: stockDayRecord) => {
      // if (row.yestoday <= -9.90) {
      //   return 'green'; 
      // } else {
      //   return 'white';
      // }
      return '#000000'
    }

    const getIncreaseTextColor = (value:number) => {

      if (value <= -9.90) {
        return 'green'; 
      } else {
        if (value <= 0 && value > -9.90) {
          return 'green'; 
        } else {
          if (value < 9.90 && value > 0) {
            return '#F56C6C'; 
          } else {
            return 'red';
          }
        }
      }
    
    }

    // 定义emit事件
    const emit = defineEmits(['selectCode']);
    const handleMouseOver =  (row: stockDayRecord) =>{
      // 当鼠标悬停在行上的逻辑
      dialogKlineVisible.value = true;
      // 触发selectCode事件，并传递数据给父组件
      emit('selectCode', { stockCode: row.code, stockName: row.name, stockTime: data.dateTime });
    }

    const getBuySailColor = (strA:string) => {
      if (strA === '买') {
        return '#F56C6C'; 
      } else {
        return '#67C23A'; 
      }
    }

    const getMoneyColor = (money:number) => {
      if (money >= 0) {
        return '#F56C6C'; 
      } else {
        return '#67C23A'; 
      }
    }

    const getMoneyStr = (money:number) => {
      if (money >= 10000 || money <= -10000) {
        return Number(money / 10000).toFixed(2) + "亿"; 
      } else {
        return money + "万"; 
      }
    }

    const getAllDifMoney = (index:number, money:number) => {
      if (index === 0) {
        if (money >= 10000 || money <= -10000) {
          return Number(money / 10000).toFixed(2) + "亿"; 
        } else {
          return money + "万"; 
        }
      } else {
        return ""; 
      }
    }

    const getAllDifMoneyColor = (money:number) => {
      if (money > 0) {
        return '#F56C6C'; 
      } else {
        return '#67C23A'; 
      }
    }

    const getIncreaseTextColorCkOpenClose = (value:number, ckOpenClose:number) => {

      if (ckOpenClose === 0) {
        return '#333333'; 
      }
      
      if (value <= -9.90) {
        return 'green'; 
      } else {
        if (value <= 0 && value > -9.90) {
          return 'green'; 
        } else {
          if (value < 9.90 && value > 0) {
            return '#F56C6C'; 
          } else {
            return 'red';
          }
        }
      }
    
    }

    const getIncreaseTextColorCkXXXXXXXXX = (row:stockDayRecord,value:number, ckOpenClose:number) => {
      console.log(row.name, value);
      if (ckOpenClose === 0) {
        return '#333333'; 
      }
      
      if (value <= -9.90) {
        return 'green'; 
      } else {
        if (value <= 0 && value > -9.90) {
          return 'green'; 
        } else {
          if (value < 9.90 && value > 0) {
            return '#F56C6C'; 
          } else {
            return 'red';
          }
        }
      }
    
    }

    const getIncreaseData = (increase:number, ckOpenClose:number) => {
        if (ckOpenClose === 1) {
          return increase + "%";
        } else { 
          return "--";  
        }
    }

    const getTableWidth = () => {
      return data.v_is_simple ? "100%" : "320px";  
    }

    const getIsShow = (isShow1:boolean, isShow2:boolean) => {
        return isShow1 && isShow2;
    } 

    const getMoneyData = (money:number) => {
      return (money / 100000000).toFixed(2) + "亿"
    }

    const getIncreaseFontWeight_Yes = (row: stockDayRecord) => {
      if (row.yestoday <= -8.0) {
        return 'bold'; 
      } else {
        return 'normal';
      }
    }
   
    const getShortNameType = (row: stockDayRecord) => {
      return "测试"; 
    }
    
    const handleSortChange = ({ column, prop, order })  => {
      console.log('排序字段:', prop);
      console.log('排序顺序:', order); // ascending, descending
      if (order === 'ascending') {
        tableDataScore.value.sort((a, b) => a[prop] - b[prop]);
      } else {
        tableDataScore.value.sort((a, b) => b[prop] - a[prop]);
      }
    }

    const handleDateChange = (val) => {
        console.log('选择了新的日期/时间:', val);
        const date = new Date(val)
        const year = date.getFullYear();
        const month = ('0' + (date.getMonth() + 1)).slice(-2); // 月份是从0开始的，所以需要加1
        const day = ('0' + date.getDate()).slice(-2);
        const dayTime = `${year}-${month}-${day}`;
        console.log('选择了新的日期/时间:', dayTime);

        const date1 = new Date(getToday());
        const date2 = new Date(dayTime);

        if (date1 < date2) {
          ElMessage({
            message: "日期不能晚于今天",
            type: "error",
          });
          return;
        }

        data.dateTime = dayTime;
        onLoadScore();
    };

    const getLink  = (row:StockNowPrice) => {
      // 动态生成链接
      return "https://www.iwencai.com/unifiedwap/result?w=" + data.dateTime + encodeURIComponent("同花顺一级行业" + row.name + "所有的涨停股票及成交金额");
    };
    const isLinkShow  = () => {
      // 动态生成链接
      return industryType.value == "同花顺行业板块"
    };
    
    const handleConditionIsOk = (row: StockIndicatorOk, value) => {
      onUpdateIndicatorOk({
        id: row.id,
        isOk: value,
      })
      setTimeout(() => {
            console.log('延迟执行的代码');
            // 在这里执行你需要延迟的操作
            onLoadCondition();
          }, 200); // 延迟2秒执行
    }

    const shouldShowButton = (row: StockIndicatorOk, value) => {
      if (row.isOk == value) {
        return true;
      }
    }

    const shouldShowButtonTigger = (row: stockDayRecord) => {
      if (row.intA === 1) {
        return true;
      } else {
        return false;
      }
    }

    const handleCondition = (row: stockDayRecord) => {
      dialogTableVisible.value = true;
      onLoadCondition();
    };

    const handleRemark = (row: stockDayRecord) => {
      data.id = row.id;
      data.strB = row.strB;
      isShowRemarkDialogTableVisible.value = true;
    };

    const onUpdate = (params) => {
      console.log("submit!" + params);
     
      axios
        .put("api/plat/stockDayRecord/update", params)
        .then((response) => {
          // console.log(response.status);
        })
        .catch((error) => {
          console.error("Error fetching data:", error);
        });
    };

    const onUpdateIndicatorOk = (params) => {
      console.log("submit!" + params);
     
      axios
        .put("api/plat/stockIndicatorOk/update", params)
        .then((response) => {
          // console.log(response.status);
        })
        .catch((error) => {
          console.error("Error fetching data:", error);
        });
    };
 
  const onAddZhiShuRecord = () => {
      console.log("submit!");
      const api = "api/plat/stockDayRecord/loadZhishuData?dayTime=" + data.dateTime;
      console.log(api) 
      axios
        .get(api)
        .then((response) => {
          
        })
        .catch((error) => {
          console.error("Error fetching data:", error);
        });
    };

    const getToday = () =>  {
      const today = new Date();
      const year = today.getFullYear();
      const month = String(today.getMonth() + 1).padStart(2, '0'); // 月份从0开始，所以要加1
      const day = String(today.getDate()).padStart(2, '0');

      return `${year}-${month}-${day}`;
    }
  </script>
    
    <style >
    .custom-border {
      border: 0.5px solid #dfe6ec;
      background-color: #000000;
    }
    
    .custom-border th, .custom-border td {
      border: 0.5px solid #dfe6ec;
      background-color: #00000000;
    }

    
    .el-table__body tr:hover > td {
      background-color: #00000000 !important;
    }
    .el-table .el-table__header th {
      color: #999;       /* 字体颜色 */
      font-weight:100; /* 字体粗细 */
      font-size: 13px;   /* 字体大小 */
      background-color: #00000000;
      /* background-color: #f5f7fa; 背景颜色（可选） */
    }

</style>